package com.bank.chat.factory;

import com.bank.model.entity.ChatRecord;
import com.bank.model.vo.chat.ChatRecordVo;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author callumEm
 * @version 1.0
 * @create 2023/4/15 11:56
 */
@Component
public class EntityFactory {
    ChatRecord chatRecord;

    private void initChatRecord(){
        this.chatRecord = new ChatRecord();
        this.chatRecord.setCreatedTime(new Date());
    }
    public ChatRecord getchatRecord(ChatRecordVo chatRecordVo){
        initChatRecord();
        this.chatRecord.setId(chatRecordVo.getId());
        this.chatRecord.setFromId(chatRecordVo.getFromId());
        this.chatRecord.setToId(chatRecordVo.getToId());
        this.chatRecord.setContent(chatRecordVo.getContent());
        this.chatRecord.setTypeEnum(chatRecordVo.getTypeEnum());
        this.chatRecord.setCreatedTime(chatRecordVo.getCreatedTime());
        return this.chatRecord;
    }
    public ChatRecord getchatRecord(Long fromId,Long toId,int type,String content){
        initChatRecord();
        this.chatRecord.setFromId(fromId);
        this.chatRecord.setToId(toId);
        this.chatRecord.setContent(content);
        this.chatRecord.setTypeEnum(type);
        return this.chatRecord;
    }
}
